package com.scsystem.xysc.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;

import lombok.Data;
import lombok.Value;

/**
 * 
 * @TableName cart
 */
@TableName(value ="cart")
@Data
public class Cart implements Serializable {

    /**
     * 购物车的id
     */
    @TableId(value = "cart_id", type = IdType.AUTO)
    private Long cartId;

    /**
     * 购物车所属用户的ID
     */
    @TableField(value = "user_id")
    private Long userId;

    /**
     * 商品的ID
     */
    @TableField(value = "product_id")
    private Long productId;

    /**
     * 商品数量
     */
    @TableField(value = "quantity")
    private Integer quantity;

    /**
     * 商品的价格（数量*价格）
     */
    @TableField(value = "product_price")
    private BigDecimal productPrice;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Cart cart = (Cart) o;
        return Objects.equals(getCartId(), cart.getCartId()) && Objects.equals(getUserId(), cart.getUserId()) && Objects.equals(getProductId(), cart.getProductId()) && Objects.equals(getQuantity(), cart.getQuantity()) && Objects.equals(getProductPrice(), cart.getProductPrice());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getCartId(), getUserId(), getProductId(), getQuantity(), getProductPrice());
    }

    @Override
    public String toString() {
        return "Cart{" +
                "cartId=" + cartId +
                ", userId=" + userId +
                ", productId=" + productId +
                ", quantity=" + quantity +
                ", productPrice=" + productPrice +
                '}';
    }
}